package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopeDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("img.png");
        FileOutputStream fos = new FileOutputStream("img_cp.png");
        int len;
        byte[] bytes = new byte[1024 * 10];//10kb 预编译特性不影响性能可读性更好
        long strat = System.currentTimeMillis();
        while ((len = fis.read(bytes))!=-1){
            fos.write(bytes,0,len);//数组开始位置和需要写入的字节长度
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕!用时:" + (end - strat)+"ms");
        fis.close();
        fos.close();
    }
}
